﻿create role [EventScavengerViewers]
GO
exec sp_addrolemember  @rolename = 'db_datareader', @membername = 'EventScavengerViewers'
GO
create role [EventScavengerAdmins]
GO
exec sp_addrolemember  @rolename = 'db_datawriter', @membername = 'EventScavengerAdmins'
GO
create role [EventScavengerCollectorUsers]
GO
exec sp_addrolemember  @rolename = 'db_datawriter', @membername = 'EventScavengerCollectorUsers'
GO

if exists(select name from sys.objects where name like 'SecurityRestoreRoles')
	drop proc SecurityRestoreRoles
GO
create proc SecurityRestoreRoles
as
  create role [EventScavengerViewers]
  exec sp_addrolemember  @rolename = 'db_datareader', @membername = 'EventScavengerViewers'
  create role [EventScavengerAdmins]
  exec sp_addrolemember  @rolename = 'db_datawriter', @membername = 'EventScavengerAdmins'
  create role [EventScavengerCollectorUsers]
  exec sp_addrolemember  @rolename = 'db_datawriter', @membername = 'EventScavengerCollectorUsers'
GO
grant execute on dbo.SecurityRestoreRoles to EventScavengerAdmins
GO